import { CreateArticleCategoryDto, UpdateArticleCategoryDto } from '@ai/entity';
import { Body, Controller, Delete, Get, Param, Patch, Post, Query } from '@nestjs/common';
import { Public } from '@/utils/metadata/public';
import { ArticleCategoryService } from './article-category.service';

@Public()
@Controller('article-category')
export class ArticleCategoryController {
    constructor(private readonly articleCategoryService: ArticleCategoryService) {}

    @Post()
    create(@Body() createArticleCategoryDto: CreateArticleCategoryDto) {
        return this.articleCategoryService.create(createArticleCategoryDto);
    }

    @Get()
    findAll() {
        return this.articleCategoryService.findAll();
    }

    @Get('query')
    findOneByValue(@Query('value') value: string) {
        return this.articleCategoryService.findAll({ value });
    }

    @Get('/with-articles')
    findListByArticles() {
        return this.articleCategoryService.findListByArticles();
    }

    @Patch(':id')
    update(@Param('id') id: string, @Body() updateArticleCategoryDto: UpdateArticleCategoryDto) {
        return this.articleCategoryService.update(id, updateArticleCategoryDto);
    }

    // 被依赖的模型不能删除
    // @Delete(':id')
    // remove(@Param('id') id: string) {
    //     return this.articleCategoryService.remove(id);
    // }
}
